package md.mru.frontend.utils;

import md.mru.core.dtos.TreeNodeModelDto;
import org.primefaces.model.TreeNode;

import java.util.Comparator;

/**
 * @author sergiu.marin
 * @since 01/09/2014.
 */
public class TreeNodeComparator implements Comparator<TreeNode> {

    @Override
    public int compare(TreeNode node1, TreeNode node2) {
        Double position1 = ((TreeNodeModelDto) node1.getData()).getPosition();
        Double position2 = ((TreeNodeModelDto) node2.getData()).getPosition();
        return position1.compareTo(position2);
    }

}
